package org.tigris.atlas.examples.service;

import java.util.ArrayList;

import junit.framework.TestCase;

import org.tigris.atlas.examples.service.delegate.ServiceDelegateFactory;
import org.tigris.atlas.examples.service.delegate.SimpleDomainServiceDelegate;
import org.tigris.atlas.examples.transfer.SimpleDomain;
import org.tigris.atlas.service.IntegerServiceResponse;

public class TestServiceCollectionParameters extends TestCase {

	private SimpleDomainServiceDelegate delegate = null;

	protected void setUp() throws Exception {
		delegate = ServiceDelegateFactory.createSimpleDomainServiceDelegate();
	}
	
	public void testService1() {
		IntegerServiceResponse resp = delegate.count(null);
		assertEquals(0, resp.getInteger().intValue());
	}

	public void testService2() {
		IntegerServiceResponse resp = delegate.count(new ArrayList());
		assertEquals(0, resp.getInteger().intValue());
	}

	public void testService3() {
		ArrayList items = new ArrayList();
		SimpleDomain one = new SimpleDomain();
		one.setId("foo");
		SimpleDomain two = new SimpleDomain();
		two.setId("bar");
		items.add(one);
		items.add(two);
		items.add(new SimpleDomain());

		IntegerServiceResponse resp = delegate.count(items);
		assertEquals(3, resp.getInteger().intValue());
	}

}
